package Offer.offer2022;

import domain.TreeNode;

/**
 * 二叉树的镜像
 */
public class Test19 {

    public static void mirrorTree(TreeNode root) {
        if (root == null || (root.left == null && root.right == null)) {
            return;
        }

        TreeNode temp = root.left;
        root.left = root.right;
        root.right = temp;

        if (root.left != null) {
            mirrorTree(root.left);
        }

        if (root.right != null) {
            mirrorTree(root.right);
        }

    }
}
